Handle errors in setting the path bar's path. Fixes #136000, based on a
authorFederico Mena Quintero <federico@ximian.com>
Wed, 3 Mar 2004 00:38:19 +0000 (00:38 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Wed, 3 Mar 2004 00:38:19 +0000 (00:38 +0000)
2004-03-02  Federico Mena Quintero  <federico@ximian.com>

* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_current_folder): Handle errors in
setting the path bar's path.  Fixes #136000, based on a patch by
Morten Welinder.

* gtk/gtkfilesystemunix.c (gtk_file_system_unix_insert_bookmark):
Don't free our own propagated error.

* gtk/gtkpathbar.c (gtk_path_bar_set_path): Likewise, and free the
parent_path upon error.  Fixes #136006, patch by Morten Welinder.
(gtk_path_bar_set_path): Unref the file_folder upon error.
(gtk_path_bar_set_path): Return a boolean success code.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c
gtk/gtkfilesystemunix.c
gtk/gtkpathbar.c
gtk/gtkpathbar.h

index bfc8abfa0ce3667a1aff7e38b7f622878312c297..3490e44d9b4e649465d80ad273fe1373afb374e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2004-03-02  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_set_current_folder): Handle errors in
+       setting the path bar's path.  Fixes #136000, based on a patch by
+       Morten Welinder.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_insert_bookmark):
+       Don't free our own propagated error.
+
+       * gtk/gtkpathbar.c (gtk_path_bar_set_path): Likewise, and free the
+       parent_path upon error.  Fixes #136006, patch by Morten Welinder.
+       (gtk_path_bar_set_path): Unref the file_folder upon error.
+       (gtk_path_bar_set_path): Return a boolean success code.
+
 Wed Mar  3 00:28:59 2004  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testcombochange.c: Add an animation mode, to test 
index bfc8abfa0ce3667a1aff7e38b7f622878312c297..3490e44d9b4e649465d80ad273fe1373afb374e5 100644 (file)
@@ -1,3 +1,18 @@
+2004-03-02  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_set_current_folder): Handle errors in
+       setting the path bar's path.  Fixes #136000, based on a patch by
+       Morten Welinder.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_insert_bookmark):
+       Don't free our own propagated error.
+
+       * gtk/gtkpathbar.c (gtk_path_bar_set_path): Likewise, and free the
+       parent_path upon error.  Fixes #136006, patch by Morten Welinder.
+       (gtk_path_bar_set_path): Unref the file_folder upon error.
+       (gtk_path_bar_set_path): Return a boolean success code.
+
 Wed Mar  3 00:28:59 2004  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testcombochange.c: Add an animation mode, to test 
index bfc8abfa0ce3667a1aff7e38b7f622878312c297..3490e44d9b4e649465d80ad273fe1373afb374e5 100644 (file)
@@ -1,3 +1,18 @@
+2004-03-02  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_set_current_folder): Handle errors in
+       setting the path bar's path.  Fixes #136000, based on a patch by
+       Morten Welinder.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_insert_bookmark):
+       Don't free our own propagated error.
+
+       * gtk/gtkpathbar.c (gtk_path_bar_set_path): Likewise, and free the
+       parent_path upon error.  Fixes #136006, patch by Morten Welinder.
+       (gtk_path_bar_set_path): Unref the file_folder upon error.
+       (gtk_path_bar_set_path): Return a boolean success code.
+
 Wed Mar  3 00:28:59 2004  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testcombochange.c: Add an animation mode, to test 
index bfc8abfa0ce3667a1aff7e38b7f622878312c297..3490e44d9b4e649465d80ad273fe1373afb374e5 100644 (file)
@@ -1,3 +1,18 @@
+2004-03-02  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_set_current_folder): Handle errors in
+       setting the path bar's path.  Fixes #136000, based on a patch by
+       Morten Welinder.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_insert_bookmark):
+       Don't free our own propagated error.
+
+       * gtk/gtkpathbar.c (gtk_path_bar_set_path): Likewise, and free the
+       parent_path upon error.  Fixes #136006, patch by Morten Welinder.
+       (gtk_path_bar_set_path): Unref the file_folder upon error.
+       (gtk_path_bar_set_path): Return a boolean success code.
+
 Wed Mar  3 00:28:59 2004  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testcombochange.c: Add an animation mode, to test 
index bfc8abfa0ce3667a1aff7e38b7f622878312c297..3490e44d9b4e649465d80ad273fe1373afb374e5 100644 (file)
@@ -1,3 +1,18 @@
+2004-03-02  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_set_current_folder): Handle errors in
+       setting the path bar's path.  Fixes #136000, based on a patch by
+       Morten Welinder.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_insert_bookmark):
+       Don't free our own propagated error.
+
+       * gtk/gtkpathbar.c (gtk_path_bar_set_path): Likewise, and free the
+       parent_path upon error.  Fixes #136006, patch by Morten Welinder.
+       (gtk_path_bar_set_path): Unref the file_folder upon error.
+       (gtk_path_bar_set_path): Return a boolean success code.
+
 Wed Mar  3 00:28:59 2004  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testcombochange.c: Add an animation mode, to test 
index 9e4e9df98fb95867105d0a27297e80fbc662ed40..ca0d7c1c1f5c849c749e612d096e9f02dc3a4f22 100644 (file)
@@ -468,7 +468,7 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
                                0);
 
   _gtk_file_chooser_install_properties (gobject_class);
-  
+
   gtk_settings_install_property (g_param_spec_string ("gtk-file-chooser-backend",
                                                      P_("Default file chooser backend"),
                                                      P_("Name of the GtkFileChooser backend to use by default"),
@@ -2245,7 +2245,7 @@ set_file_system_backend (GtkFileChooserDefault *impl,
     {
       GtkSettings *settings = gtk_settings_get_default ();
       gchar *default_backend = NULL;
-      
+
       g_object_get (settings, "gtk-file-chooser-backend", &default_backend, NULL);
       if (default_backend)
        {
@@ -2837,14 +2837,24 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
                                             const GtkFilePath *path)
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+  GError *error;
 
-  if (impl->current_folder)
-    gtk_file_path_free (impl->current_folder);
+  error = NULL;
+  if (!gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, &error))
+    {
+      error_dialog (impl,
+                   _("Could not set current folder: %s"),
+                   path, error);
+      return;
+    }
 
-  impl->current_folder = gtk_file_path_copy (path);
+  if (impl->current_folder != path)
+    {
+      if (impl->current_folder)
+       gtk_file_path_free (impl->current_folder);
 
-  /* Change the current folder label */
-  gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, NULL);
+      impl->current_folder = gtk_file_path_copy (path);
+    }
 
   /* Update the widgets that may trigger a folder chnage themselves */
 
@@ -3362,12 +3372,12 @@ gtk_file_chooser_default_get_resizable_hints (GtkFileChooserEmbed *chooser_embed
 
   g_return_if_fail (resize_horizontally != NULL);
   g_return_if_fail (resize_vertically != NULL);
-  
+
   impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
 
   *resize_horizontally = TRUE;
   *resize_vertically = TRUE;
-  
+
   if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
       impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
     {
index 77649316fa8773a9acf89f3a96556173697d5eac..0b54133a7a5ed7d8af2c2b41b24ce2e094547cd7 100644 (file)
@@ -1086,7 +1086,6 @@ gtk_file_system_unix_insert_bookmark (GtkFileSystem     *file_system,
   if (!bookmark_list_read (&bookmarks, &err) && err->code != G_FILE_ERROR_NOENT)
     {
       g_propagate_error (error, err);
-      g_error_free (err);
       return FALSE;
     }
 
index 78e5e4f44bea27a88d460c0ef845a0113b9230be..66893493ae18846d365efb4ab4bd1dc007493d56 100644 (file)
@@ -629,7 +629,7 @@ make_directory_button (const char  *dir_name,
 }
 
 
-void
+gboolean
 gtk_path_bar_set_path (GtkPathBar         *path_bar,
                       const GtkFilePath  *file_path,
                       GtkFileSystem      *file_system,
@@ -637,10 +637,13 @@ gtk_path_bar_set_path (GtkPathBar         *path_bar,
 {
   GtkFilePath *path;
   gboolean first_directory = TRUE;
-  
-  g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
-  g_return_if_fail (file_path != NULL);
-  g_return_if_fail (file_system != NULL);
+  gboolean result;
+
+  g_return_val_if_fail (GTK_IS_PATH_BAR (path_bar), FALSE);
+  g_return_val_if_fail (file_path != NULL, FALSE);
+  g_return_val_if_fail (file_system != NULL, FALSE);
+
+  result = TRUE;
 
   gtk_path_bar_clear_buttons (path_bar);
   path = gtk_file_path_copy (file_path);
@@ -663,8 +666,8 @@ gtk_path_bar_set_path (GtkPathBar         *path_bar,
                                          &err);
       if (!valid)
        {
+         result = FALSE;
          g_propagate_error (error, err);
-         g_error_free (err);
          gtk_file_path_free (path);
          break;
        }
@@ -679,8 +682,10 @@ gtk_path_bar_set_path (GtkPathBar         *path_bar,
       file_info = gtk_file_folder_get_info (file_folder, path, &err);
       if (!file_info)
        {
+         result = FALSE;
          g_propagate_error (error, err);
-         g_error_free (err);
+         g_object_unref (file_folder);
+         gtk_file_path_free (parent_path);
          gtk_file_path_free (path);
          break;
        }
@@ -703,4 +708,6 @@ gtk_path_bar_set_path (GtkPathBar         *path_bar,
   gtk_widget_pop_composite_child ();
 
   path_bar->button_list = g_list_reverse (path_bar->button_list);
+
+  return result;
 }
index 51d567188ec79ed9323a82591e43b5101da3d0ea..f058af2ba4060f10d71d947fcc970865e185a900 100644 (file)
@@ -59,10 +59,10 @@ struct _GtkPathBarClass
 };
 
 GType gtk_path_bar_get_type (void) G_GNUC_CONST;
-void  gtk_path_bar_set_path (GtkPathBar         *path_bar,
-                            const GtkFilePath  *file_path,
-                            GtkFileSystem      *file_system,
-                            GError            **error);
+gboolean gtk_path_bar_set_path (GtkPathBar         *path_bar,
+                               const GtkFilePath  *file_path,
+                               GtkFileSystem      *file_system,
+                               GError            **error);
 G_END_DECLS
 
 #endif /* __GTK_PATH_BAR__ */